
#include <iostream>
#include <vector>
using namespace std;

bool row[10][10], col[10][10], gird[3][3][10];
bool dfs(vector<vector<char>>& board);

void solveSudoku(vector<vector<char>>& board) {
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (board[i][j] != '.')
            {
                int x = board[i][j] - '0';
                row[i][x] = col[j][x] = gird[i / 3][j / 3][x] = true;
            }
        }
    }
    dfs(board);
}
bool dfs(vector<vector<char>>& board)
{
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (board[i][j] == '.')
            {
                for (int k = 1; k <= 9; k++)
                {
                    if (!row[i][k] && !col[j][k] && !gird[i / 3][j / 3][k])
                    {
                        board[i][j] = k + '0';
                        row[i][k] = col[j][k] = gird[i / 3][j / 3][k] = true;
                        if (dfs(board) == true) return true;
                        board[i][j] = '.';
                        row[i][k] = col[j][k] = gird[i / 3][j / 3][k] = false;
                    }
                }
                return false;
            }
        }
    }
    return true;
}

int main()
{
    vector<vector<char>>board(10);
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            char ch;
            cin >> ch;
            board[i].push_back(ch);
        }
        getchar();
    }
    solveSudoku(board);
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            cout << board[i][j];
        }
        cout << endl;
    }
    return 0;
}